import config from "@/config"
import http from "@/utils/request"

export default {
  getKeywordList: {
    url: `${config.API_URL}/keyWords/list`,
    name: "关键字列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  addKeyword: {
    url: `${config.API_URL}/keyWords/add`,
    name: "添加关键字",
    post: function (param) {
      return new Promise((resolve, reject) => {
        http.post(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updateKeyword: {
    url: `${config.API_URL}/keyWords/update`,
    name: "修改关键字",
    post: function (param) {
      return new Promise((resolve, reject) => {
        http.post(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteKeyword: {
    url: `${config.API_URL}/keyWords/deleted`,
    name: "删除关键字",
    delete: function (param) {
      return new Promise((resolve, reject) => {
        http.delete(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  }
}